package seed_partner_admin

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/partner/partner_admin/partner_admin_users"
	"gitee.com/theegg/go-brick/app/service/app"
	"gitee.com/theegg/go-brick/app/service/help/cbcrypt"
	"time"
)

func InitPartnerAdminUserSeed() {
	items := make(map[int]partner_admin_users.PartnerAdminUsers)

	items[1] = partner_admin_users.PartnerAdminUsers{
		Id:            1,
		Email:         "admin@gmail.com",
		Username:      "admin",
		ImageAvatar:   "admin_user/avatar/default.jpeg",
		Password:      cbcrypt.Make("1234qwer"),
		SecPassword:   cbcrypt.Make("qwer1234"),
		Remark:        "超级管理员",
		Lang:          "cn",
		RegisterTime:  time.Now().Unix(),
		RegisterIp:    "127.0.0.1",
		LastLoginTime: time.Now().Unix(),

		State: 1,
	}

	items[2] = partner_admin_users.PartnerAdminUsers{
		Id:            2,
		Email:         "jiangpengju2010@gmail.com",
		Username:      "admin",
		ImageAvatar:   "",
		Password:      cbcrypt.Make("1234qwer"),
		SecPassword:   cbcrypt.Make("qwer1234"),
		Remark:        "超级管理员",
		Lang:          "cn",
		RegisterTime:  time.Now().Unix(),
		RegisterIp:    "127.0.0.1",
		LastLoginTime: time.Now().Unix(),

		State: 1,
	}

	items[3] = partner_admin_users.PartnerAdminUsers{
		Id:            3,
		Email:         "yyjl@gmail.com",
		Username:      "kfjl",
		ImageAvatar:   "",
		Password:      cbcrypt.Make("1234qwer"),
		SecPassword:   cbcrypt.Make("qwer1234"),
		Remark:        "运营经理",
		Lang:          "en",
		RegisterTime:  time.Now().Unix(),
		RegisterIp:    "127.0.0.1",
		LastLoginTime: time.Now().Unix(),

		State: 1,
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := app.Db().Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "partner_admin_users", count, errCount)
}
